﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Kaidou.Model;
using Kaidou.Persister;
using Kaidou.Util;

public partial class master_master_union_view : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        LoginModel loginModel = (LoginModel)Session["loginModel"];

        if (loginModel == null)
        {
            Response.Redirect("../login.aspx");
        }
        else if (!loginModel.isOperator() && !loginModel.isJimukyoku())
        {
            Response.Redirect("../menu.aspx");
        }

        if ("on".Equals(Resources.Resource.kaidou_view_user_clss))
        {
            user_clss_panel.Visible = true;
        }
        else
        {
            user_clss_panel.Visible = false;
        }

        



        if (!IsPostBack)
        {
            string area = Resources.Resource.area;
            string[] areaArray = area.Split(',');


            MST_UnionPersister dao = new MST_UnionPersister();
            MstUnion M = dao.getDetail(Request.QueryString["unioncode"].ToString());
            Session["mstunion"] = M;

            union_code.Text = M.Id.UnionCode;
            office_address.Text = M.OfficeAddress;
            office_city.Text = M.OfficeCity;
            office_email.Text = M.OfficeEmail;
            office_fax.Text = M.OfficeFax;
            office_kana.Text = M.OfficeKana;
            office_name.Text = M.OfficeName;
            office_pref_code.Text = areaArray[M.OfficePrefCode - 1];
            office_tel.Text = M.OfficeTel;
            office_zip_no1.Text = M.OfficeZipNo.Substring(0, 3);
            office_zip_no2.Text = M.OfficeZipNo.Substring(3, 4);
            tanto_kana.Text = M.TantoKana;
            tanto_name.Text = M.TantoName;
            if (M.TraderRegNo != null && M.TraderRegNo.Trim().Length > 0)
            {
                trader_reg_no1.Text = M.TraderRegNo.Substring(0, 2);
                trader_reg_no2.Text = M.TraderRegNo.Substring(2, 5);
            }

            daihyo_name.Text = M.DaihyoName;
            daihyo_kana.Text = M.DaihyoKana;

            user_class.Text = int.Parse(M.UserClss) == 10 ? "組合員" : int.Parse(M.UserClss) == 20 ? "事務局" : "オペレータ";
            password.Text = M.Password;
        }

    }


   
    protected void goback(object sender, EventArgs e)
    {
        Session["back"] = 1;
        Response.Redirect("master_union_search.aspx");

    }
}
